package com.hunqiu.user.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.hunqiu.user.dao.UserDAO;
import com.hunqiu.user.vo.UserQueueVO;
import com.hunqiu.user.vo.UserVO;

public class UserDAOImpl implements UserDAO {

	private SqlMapClientTemplate sqlMapClientTemplate;

	public void setSqlMapClientTemplate(
			SqlMapClientTemplate sqlMapClientTemplate) {
		this.sqlMapClientTemplate = sqlMapClientTemplate;
	}

	@Override
	public List<UserVO> getAllUser() {

		return this.sqlMapClientTemplate.queryForList("UserDAO.queryAll");
	}

	@Override
	public UserVO getUserById(long uid) {
		Map<String,Object> paras = new HashMap<String, Object>();
		paras.put("uid", uid);
		return (UserVO) this.sqlMapClientTemplate.queryForObject(
				"UserDAO.queryById", paras);
	}

	@Override
	public List<UserQueueVO> getUserQueue() {

		return this.sqlMapClientTemplate.queryForList("UserDAO.queryUserQueue");
	}

	@Override
	public void deleteUserQueueById(long id) {
		Map<String,Object> paras = new HashMap<String, Object>();
		paras.put("id", id);
		this.sqlMapClientTemplate.delete("UserDAO.deleteUserQueueById", paras);
	}

}
